#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

/*
分层图问题
*/

using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 1e6 + 10, inf = 0x3f3f3f3f;

int n, m, k;
vector<int> e[N], w[N];
int dist[N];
bool st[N];


int dijkstra(){
    priority_queue<PII, vector<PII>, greater<PII>> heap;
    
    for(int i = 1; i <= n * 2; i ++) dist[i] = inf;
    dist[1] = 0;
    heap.push({0, 1});

    while(!heap.empty()){
        PII temp = heap.top();
        heap.pop();

        int dis = temp.first, ver = temp.second;

        if(st[ver]) continue;
        st[ver] = true;

        for(int i = 0; i < e[ver].size(); i ++){
            int j = e[ver][i];

            if(dist[j] > dis + w[ver][i]){
                dist[j] = dis + w[ver][i];
                heap.push({dist[j], j});
            }
        }
    }

    if(dist[n] >= inf && dist[n * 2] >= inf){
        return -1;
    }else{
        return min(dist[n], dist[n * 2]);
    }


}



int main(){
#ifdef LOCALFLAG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    ios::sync_with_stdio(false);
    cin.tie(nullptr);


    cin >> n >> m >> k;

    int ta, tb, tf;
    for(int i = 1; i <= m; i ++){
        cin >> ta >> tb >> tf;

        if(tf == 1){
            e[ta].push_back(tb);
            w[ta].push_back(1);

            e[tb].push_back(ta);
            w[tb].push_back(1);
        }else{
            e[n + ta].push_back(n + tb);
            w[n + ta].push_back(1);

            e[n + tb].push_back(n + ta);
            w[n + tb].push_back(1);
        }
    }

    for(int i = 1, x; i <= k; i ++){
        cin >> x;

        e[x].push_back(x + n);
        w[x].push_back(0);
        
        e[x + n].push_back(x);
        w[x + n].push_back(0);
    }

    int k = dijkstra();

    cout << k << '\n';


    return 0;
}